<?php

namespace app\request;

use think\Validate;

class Account extends Validate
{

    protected $scene = [
        'register' => ['account', 'password', 'repassword', 'mch_id', 'game_id'],
        'login' => ['account', 'password', 'mch_id', 'game_id'],
        'phone-login' => ['phone', 'code', 'mch_id', 'game_id'],
        'get-info' => ['mch_id', 'game_id'],
        'reset-password' => ['account', 'old_password', 'new_password', 're_password'],
        'reset-secret-protection' => ['account', 'password', 'old_secret_protection', 'old_answer', 'new_secret_protection', 'new_answer'],
        'real-name-submit' => ['token', 'name', 'id_number'],
        'bind-phone' => ['account', 'secret_protection', 'answer', 'phone', 'code', 'mch_id', 'game_id'],
        'modify-phone' => ['account', 'old_phone', 'old_phone_code', 'phone', 'code', 'mch_id', 'game_id'],
    ];


    protected $rule = [
        'account' => 'require|alphaNum|min:5|max:20',
        'phone' => 'require|length:11',
        'old_phone' => 'require|length:11',
        'code' => 'require|length:6',
        'old_phone_code' => 'require|length:6',
        'password' => 'require|length:32',
        'repassword' => 'require|confirm:password',
        'mch_id' => 'require',
        'game_id' => 'require',
        'old_password' => 'require|length:32',
        'new_password' => 'require|length:32|different:old_password',
        're_password' => 'require|length:32|confirm:new_password',
        'new_secret_protection' => 'require',
        'new_answer' => 'require',
        'name' => 'require',
        'id_number' => 'require|idCard',
        'secret_protection' => 'require',
        'answer' => 'require',
    ];


    protected $message = [
        'account.require' => '账号不能为空',
        'account.alphaDash' => '账号只能包含字母、数字',
        'account.min' => '账号不能小于5个字符',
        'account.max' => '账号不能超过20个字符',
        'old_phone.require' => '原手机号不能为空',
        'old_phone.length' => '原手机号格式不正确',
        'phone.require' => '手机号不能为空',
        'phone.length' => '手机号格式不正确',
        'old_phone_code.require' => '原手机号验证码不能为空',
        'old_phone_code.length' => '原手机号验证码格式不正确',
        'code.require' => '验证码不能为空',
        'code.length' => '验证码格式不正确',
        'password.require' => '密码不能为空',
        'password.length' => '密码格式不正确',
        'repassword.require' => '请确认密码',
        'repassword.confirm' => '两次密码不一致',
        'mch_id.require' => '商户不能为空',
        'game_id.require' => '游戏不能为空',
        'old_password.require' => '旧密码不能为空',
        'old_password.length' => '旧密码格式不正确',
        'new_password.require' => '新密码不能为空',
        'new_password.length' => '新密码格式不正确',
        'new_password.different' => '新密码与旧密码相同',
        're_password.require' => '确认新密码不能为空',
        're_password.length' => '确认新密码格式不正确',
        're_password.confirm' => '确认新密码不一致',
        'new_secret_protection.require' => '请设置新密保问题',
        'new_answer.require' => '请设置新密保问题答案',
        'name.require' => '请填写真实姓名',
        'id_number.require' => '请填写身份证号',
        'id_number.idCard' => '身份证号格式不正确',
        'secret_protection.require' => '密保问题不能为空',
        'answer.require' => '密保问题答案不能为空',
    ];

}